package com.anyou.mall.bucket.controller;

import java.math.BigDecimal;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.anyou.mall.bucket.dto.AuditDto;
import com.anyou.mall.bucket.dto.AuditDto2;
import com.anyou.mall.bucket.dto.BucketAuditDto;
import com.anyou.mall.bucket.dto.CertDto;
import com.anyou.mall.bucket.vo.BucketAuditVo;
import com.anyou.mall.bucket.vo.BucketAuditVo2;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.bucket.domain.ReturnBucketAudit;
import com.anyou.mall.bucket.service.IReturnBucketAuditService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 退还桶押金审核Controller
 *
 * @author ruoyi
 * @date 2023-10-11
 */
@Api(tags = "退还桶押金审核")
@RestController
@RequestMapping("/bucket/audit")
public class ReturnBucketAuditController extends BaseController
{
    @Autowired
    private IReturnBucketAuditService returnBucketAuditService;

    /**
     * 查询退还桶押金审核列表
     */
    @ApiOperation("查询退还桶押金审核列表")
    @PreAuthorize("@ss.hasPermi('bucket:audit:list')")
    @GetMapping("/list")
    public TableDataInfo<List<BucketAuditVo>> list(BucketAuditDto param)
    {
        startPage();
        List<BucketAuditVo> list = returnBucketAuditService.selectBucketAuditList(param);
        return getDataTable(list);
    }

    /**
     * 导出退还桶押金审核列表
     */
    @ApiOperation("导出退还桶押金审核列表")
    @PreAuthorize("@ss.hasPermi('bucket:audit:export')")
    @Log(title = "退还桶押金审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BucketAuditDto param)
    {
        List<BucketAuditVo> list = returnBucketAuditService.selectBucketAuditList(param);
        ExcelUtil<BucketAuditVo> util = new ExcelUtil<BucketAuditVo>(BucketAuditVo.class);
        util.exportExcel(response, list, "退还桶押金审核数据");
    }


    /**
     * 获取退还桶押金审核详细信息
     */
    @ApiOperation("获取退还桶押金审核详细信息")
    @PreAuthorize("@ss.hasPermi('bucket:audit:query')")
    @GetMapping(value = "/{returnBucketAuditId}")
    public ApiResult<ReturnBucketAudit> getInfo(@PathVariable("returnBucketAuditId") Long returnBucketAuditId)
    {
        return ApiResult.success(returnBucketAuditService.selectReturnBucketAuditByReturnBucketAuditId(returnBucketAuditId));
    }

    /**
     * 新增退还桶押金审核
     */
    @ApiOperation("新增退还桶押金审核")
    @PreAuthorize("@ss.hasPermi('bucket:audit:add')")
    @Log(title = "退还桶押金审核", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody ReturnBucketAudit returnBucketAudit)
    {
        return ApiResult.success(returnBucketAuditService.insertReturnBucketAudit(returnBucketAudit));
    }

//    /**
//     * 修改退还桶押金审核
//     */
//    @ApiOperation("修改退还桶押金审核")
//    @PreAuthorize("@ss.hasPermi('bucket:audit:edit')")
//    @Log(title = "退还桶押金审核", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public ApiResult edit(@RequestBody ReturnBucketAudit returnBucketAudit)
//    {
//        return ApiResult.success(returnBucketAuditService.updateReturnBucketAudit(returnBucketAudit));
//    }
    /**
     * 修改转账凭证
     */
    @ApiOperation("修改转账凭证")
    @PreAuthorize("@ss.hasPermi('bucket:audit:editCert')")
    @Log(title = "修改转账凭证", businessType = BusinessType.UPDATE)
    @PostMapping("/editCert")
    public ApiResult editCert(@RequestBody CertDto param)
    {
        ReturnBucketAudit returnBucketAudit = new ReturnBucketAudit();
        BeanUtils.copyProperties(param,returnBucketAudit);
        return ApiResult.success(returnBucketAuditService.updateReturnBucketAudit(returnBucketAudit));
    }

    /**
     * 审核通过/不通过
     */
    @ApiOperation("审核通过/不通过")
    @PreAuthorize("@ss.hasPermi('bucket:audit:editAudit')")
    @Log(title = "审核通过/不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/editAudit")
    public ApiResult editAudit(@RequestBody AuditDto param)
    {
        ReturnBucketAudit returnBucketAudit = new ReturnBucketAudit();
        BeanUtils.copyProperties(param,returnBucketAudit);
        return ApiResult.success(returnBucketAuditService.updateReturnBucketAudit(returnBucketAudit));
    }
    /**
     * 退还桶押金详情
     */
    @ApiOperation("退还桶押金详情")
    @PreAuthorize("@ss.hasPermi('bucket:audit:bucketInfo')")
    @Log(title = "退还桶押金详情", businessType = BusinessType.UPDATE)
    @PostMapping("/bucketInfo")
    public ApiResult bucketInfo(@RequestBody AuditDto2 param)
    {
        BucketAuditVo2 bucketAuditVo2=returnBucketAuditService.selectBucketInfo(param.getReturnBucketAuditId());
        return ApiResult.success(bucketAuditVo2);
    }
//
//    /**
//     * 删除退还桶押金审核
//     */
//    @ApiOperation("删除退还桶押金审核")
//    @PreAuthorize("@ss.hasPermi('bucket:audit:remove')")
//    @Log(title = "退还桶押金审核", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{returnBucketAuditIds}")
//    public ApiResult remove(@PathVariable Long[] returnBucketAuditIds)
//    {
//        return ApiResult.success(returnBucketAuditService.deleteReturnBucketAuditByReturnBucketAuditIds(returnBucketAuditIds));
//    }
}
